<?php
my_component_load('testing' , false);
my_component_load('paging' , false); 
my_component_load('data_setting', false);
my_component_load('jabatan_physical' );
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$jid = isset( $_GET['jid'] ) ? $_GET['jid']:  0;
$modulname = "Admin _BN_ Konfigurasi Data";

if($_SERVER['REQUEST_METHOD'] == "POST" ):
    $validatepost = form_jabatan_physical_validate($id);
	switch($task){
		case   "jabatan_physicalcreate" :
			if($validatepost)
			{
				$errors = message_multi_error($validatepost);
				$content = $errors;
				$content .= form_jabatan_physical_create($id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
					form_jabatan_physical_submit($id);
					$content =  "Updated";
					generate_my_web($content,"","plain.php");
					exit;
			     }
		break;
		case "add_link_page":
			add_link_jabatan_submi($jid);
			$content =  "Updated";
			generate_my_web($content,"","plain.php");
			exit;
		break;
		case   "jabatancreate" :
			form_jabatan_submit();
			$content =  "Updated";
			generate_my_web($content,"","plain.php");
			exit;
		break;
	}

else: 	
	$_SESSION['tab_page'] = '#tab0';
	if($task == "editjabatan_physical"){
		$title= ($id > '0' ) ?  "Perubahan data" : "Tambah data";
		facebox_page('index.php?com=jabatan_physical&task=jabatan_physicalcreate&id='.$id , $title , 300	); 
	}elseif($task == "jabatan_physicalcreate"){ 
		$content  = form_jabatan_physical_create($id);
		generate_my_web($content,"","plain.php");
		exit; 
	}elseif($task =='add_link'){
		$title=    "Data Spesifikasi Fisik"  ;
		facebox_page('index.php?com=jabatan_physical&task=add_link_page&jid='.$jid , $title , 140	); 
	}elseif($task =='add_link_page'){
		generate_my_web(add_link_jabatan($id),"","plain.php");
		exit;
	}elseif($task == 'ans'){
		$query = "UPDATE jabatan_spesifikasi_link 
				SET jawaban =''
				WHERE jabatan_id = {$_GET['jid']} 
				AND jabatan_physical_id = {$_GET['jsid']} ";
		 my_query($query);
		 $jawaban = urldecode($_GET['jawaban']);
		 if(	trim($_GET['jawaban']) <> "" ||	 $jawaban <> "undefined"){
		$query = "UPDATE jabatan_spesifikasi_link 
				SET jawaban ='".$jawaban."'
				WHERE jabatan_id = {$_GET['jid']} 
				AND jabatan_physical_id = {$_GET['jsid']} ";
			//print($query);
		my_query($query);
		
		 }
		 my_direct($_SERVER['HTTP_REFERER']);
	}elseif($task == 'delete'){ // DELETE ITEM	
		remove_jabatan_physical($id);
		my_direct('index.php?com=jabatan_physical');
	}else{
		$pagename = "Data kualifikasi";
		load_facebox_script();
		$view =  list_jabatan_physical(); 
		
	}
endif; 
$content = spliter_browser( $view , $pagename ,'index.php?com=jabatan_physical&task=editjabatan_physical');
generate_my_web($content, $modulname." _BN_ Kualifikasi" );
?>